/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.ShareRecordMapper;
import com.ybkj.daijia.server.model.ShareRecord;
import com.ybkj.daijia.server.service.ShareRecordService;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultShareRecordService implements ShareRecordService {

    @Autowired
    private ShareRecordMapper shareRecordMapper;


    @Transactional(rollbackFor = Exception.class)
    public ShareRecord insertRecord(ShareRecord shareRecord) {

        shareRecordMapper.insertRecord(shareRecord);

        return shareRecord;
    }

    public ShareRecord findOne(Long id) {

        return shareRecordMapper.selectByPrimaryKey(id);
    }


    @Transactional(rollbackFor = Exception.class)
    public void delete(ShareRecord shareRecord) {

        shareRecordMapper.deleteByPrimaryKey(shareRecord.getId());

    }

    @Override
    public Long countByMemberId(Long memberId) {

        return shareRecordMapper.countByMemberId(memberId);
    }

    @Override
    public Long countByMemberAndActivity(Long memberId, Long activityId, Date startDate,
        Date endDate) {

        return shareRecordMapper.countByMemberAndactivity(memberId, activityId, startDate, endDate);
    }


}